package com.example.fitapp.activity.splash;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

import com.example.fitapp.activity.activity.LoginActivity;
import com.example.fitapp.activity.R;
import com.example.fitapp.activity.activity.MainActivityWithTap;

public class SplashActivity extends Activity {
//    设置启动时间
    private static final long DELAY_TIME = 3000L;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                SharedPreferences pref = getSharedPreferences("data",MODE_PRIVATE);
                String token = pref.getString("token","");
                if(token!=""){
                    startActivity(new Intent(SplashActivity.this, MainActivityWithTap.class));
                    finish();
                }else{
                    startActivity(new Intent(SplashActivity.this, LoginActivity.class));
                    finish();
                }

            }
        },DELAY_TIME);
    }
}
